<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%
String path = request.getContextPath();
%>
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %>
<html:html locale="true">
<head>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<title></title>
<link href="console.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.style1 {font-size: 16px}
-->
.even {
	background:	#eee;
}

.odd {

}
</style>
</head>

<body>
<jsp:include page="/title.jsp" flush="true"/>

	<p class="lnkhead2">
	<logic:equal name="roleType" value="process">
	<bean:message key='menu.engines'/>&gt;<bean:write name="domain"/>&gt;<bean:message key='menu.roles'/>
	</logic:equal>
	<logic:equal name="roleType" value="workitem">
	<bean:message key='menu.taskManagers'/>&gt;<bean:write name="domain"/>&gt;<bean:message key='menu.roles'/>
	</logic:equal>
	</p>
	<form name="form" method="post" action="role.do">
	<input type="hidden" name="act"/>
		<input type="hidden" name="roleId"/>
	<input type="hidden" name="domain" value="<bean:write name='domain'/>"/>
	<input type="hidden" name="roleType" value="<bean:write name='roleType'/>"/>
	  <table width="100%" border="0" cellpadding="1" class="sort-table" id="table-1" cellspacing="0">
	
	<thead>
			
			<tr >
			<td align="center">&nbsp;</td>
				
				<td align="center" width="20%">
					
					ID
					
				</td>
				
				<td align="center" width="20%">
					
					<bean:message key='heading.name'/>
					
				</td>
				
				
				<td align="center" width="55%">
					
					<bean:message key='heading.desc'/>
					
				</td>
				
			</tr>
	  </thead>
			<tbody>
			<% int i=0; String color;String check="";%>
			
			<logic:iterate id="attr" name="roleList">
				
				<% i++; if(i%2==1) color="odd"; else color="even"; if(i==1) check="checked"; else check="";%>
				
				<tr  class="<%=color%>">
					<td align="center">
					<input type="radio" <%=check%> name="idIndex"  value="<bean:write name='attr' property='id'/>" />
								
					</td>
					<td align="left">
						
						<bean:write name="attr" property="id"/>
						
					</td>
					
					<td align="left">
					<bean:write name="attr" property="name"/>
					</td>
					<td align="center">
						<bean:write name="attr" property="desc"/>
						
					</td>
					
				</tr>
			
			</logic:iterate>
	  </tbody>
</table>
	<table width="100%">		
			<tr >
				
				<td align="left">
					<input  type="button" name="Submit" value="<bean:message key='button.add'/>" onclick="javascript:add1()"/>
					<input  type="button" name="Submit1" value="<bean:message key='button.update'/>" onclick="javascript:update1()"/>
					<input  type="button" name="Submit2" value="<bean:message key='button.delete'/>" onclick="javascript:del()"/>
					<input  type="button" name="Submit3" value="<bean:message key='role.permission'/>" onclick="javascript:acl()"/>
					</td>
			</tr>
</table>
		<div id="add_form"  style="visibility:hidden; z-index:2" >
		
		<table width="100%" border="0" cellpadding="0"  cellspacing="0">	
		<tr  class="txtnormal2">			

			<td  width="16%">ID
				
				<input type="text" name="id"  size="12"/>
				
			</td>
				<td  width="25%"><bean:message key='heading.name'/>
				
				<input type="text" name="name"   size="16"/>
				
			</td>
			
			<td  width="45%"><bean:message key='heading.desc'/>
				<input type="textarea" name="desc" size="40" />
				</td>
	
			<td width="10%">
			<input type="button" name="add_button" value='<bean:message key="action.add"/>' onclick="javascript:add()" >
			</td>
	</tr>
</table>
</div>	
	<script  language="JavaScript">
	function add()
	{
		var frm = document.forms["form"];
		
		if(frm.elements["act"].value =="add"){
			if(!checkId(frm.elements["id"],"ID")){
				return;
			}
		}else{
			var id=selectedRadiobox(frm,"idIndex");
			if(id==null) return;
			frm.elements["roleId"].value=id;
		}
		if(frm.elements["name"].value=="")
		{
			 alert("<bean:message key='button.needName'/>");
			return;
		}
		frm.submit();
	
	}
		 </script>
	 
<script type="text/javascript">

	function del()
	{
		var frm = document.forms["form"];
		var id=selectedRadiobox(frm,"idIndex");
		if(id==null) return;
		if( !confirm("<bean:message key='button.confirmDelete'/>ID:"+id)) return;
		frm.elements["act"].value="delete";
		frm.elements["roleId"].value=id;
		frm.submit();
	}
	 </script>
	 <script type="text/javascript">

	function acl()
	{
		var frm = document.forms["form"];
		var id=selectedRadiobox(frm,"idIndex");
		if(id==null) return;
		frm.elements["act"].value="acl";
		frm.elements["roleId"].value=id;
		frm.submit();
	}
	 </script>
	 
<script type="text/javascript">	
	function update1()
	{
	var frm = document.forms["form"];
	var id=selectedRadiobox(frm,"idIndex");
	if(id==null) return;
	frm.elements["id"].value = id;
	frm.elements["id"].disabled = true;
	frm.elements["add_button"].value = "<bean:message key='button.update'/>";
	frm.elements["act"].value = "update";
	shift_visibility(add_form);
	};
	
	

function add1()
	{
	var frm = document.forms["form"];
	
	frm.elements["id"].disabled = false;
	frm.elements["add_button"].value = "<bean:message key='button.add'/>";
	frm.elements["act"].value = "add";
	shift_visibility(add_form);
	};

	function shift_visibility(image1){
 if(image1.style.visibility == "visible")
  image1.style.visibility = "visible";
  else  image1.style.visibility = "visible";
}
	 </script>
	 
<script type="text/javascript">
var st = new SortableTable(document.getElementById("table-1"),
	["None", "String","String",  "String"]);
</script>
<logic:notEmpty name="returnMsg">
	<script>
	alert('<bean:write name="returnMsg"/>');
	</script>
	</logic:notEmpty>
<%@ include file="/table_bottom.jsp" %>
</body>
</html:html>



